<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>角色列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
    <table id="rolesList" lay-filter="rolesList"></table>

    <!--操作-->
    <script type="text/html" id="rolesListBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
        <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="look">预览</a>
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="assignRight">分配权限</a>
    </script>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table;
        //用户列表
        var tableIns = table.render({
            elem: '#rolesList',
            url : 'roles',
            page : true,
            limit : 20,
            limits : [10,15,20,25],
            id : "rolesListTable",
            cols : [[
                {type: "checkbox", fixed:"left"},
                {field: 'id', title: '编号',align:"center"},
                {field: 'rolename', title: '角色名',align:"center"},
                {title: '操作', width:250, templet:'#rolesListBar',fixed:"right",align:"center"}
            ]]
        });
        table.on("tool(rolesList)",function (obj) {
            //获取当前行的数据
            var data=obj.data;
            switch (obj.event){
                case 'assignRight':
                    assignRight(data);
                    break;
            }
        });
        //分配权限
        function assignRight(data){
            var index=layui.layer.open({
                title:"分配权限",
                type:2,
                area:['300px','500px'],
                content:"toAssignRightPage.do",
                success:function (layero,index) {
                    var body = layui.layer.getChildFrame('body', index);
                    body.contents().find("#roleIdHiden").val(data.id);
                }
            });
        }


    })

</script>
</body>
</html>